Add `src/**/*.rs.bk` to VCS ignore file
authorSander Maijers <S.N.Maijers@gmail.com>
Fri, 24 Feb 2017 18:17:46 +0000 (19:17 +0100)
committerSander Maijers <S.N.Maijers@gmail.com>
Fri, 24 Feb 2017 18:17:46 +0000 (19:17 +0100)
Limit `target` exclusion to `target/` dirs.

src/cargo/ops/cargo_new.rs

index d211dc3e9b64d9d924ca2c4fd922b3a4e3d47eae..4921db34db85da823ecbf023de2861bd4e7c6b3e 100644 (file)
@@ -435,19 +435,17 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
     let path = opts.path;
     let name = opts.name;
     let cfg = global_config(config)?;
-    let mut ignore = "target\n".to_string();
-    let in_existing_vcs_repo = existing_vcs_repo(path.parent().unwrap(), config.cwd());
-    if !opts.bin {
-        ignore.push_str("Cargo.lock\n");
-    }
+    let ignore = ["target/\n", "src/**/*.rs.bk\n",
+        if !opts.bin { "Cargo.lock\n" } else { "" }]
+        .concat();
 
+    let in_existing_vcs_repo = existing_vcs_repo(path.parent().unwrap(), config.cwd());
     let vcs = match (opts.version_control, cfg.version_control, in_existing_vcs_repo) {
         (None, None, false) => VersionControl::Git,
         (None, Some(option), false) => option,
         (Some(option), _, _) => option,
         (_, _, true) => VersionControl::NoVcs,
     };
-
     match vcs {
         VersionControl::Git => {
             if !fs::metadata(&path.join(".git")).is_ok() {